package com.kerwin.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*乐观锁插件*/
/*自己建立配置类，把配置类放到容器里面*/
@Configuration
public class MybatisPlusConfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        /*mp的插件注册  就是个拦截器*/
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        /*添加拦截器*/
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }
}
